<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //map是一组键值对的结构
      //set:设置  get：获取   size：长度     has：判断   delete：清除某个 clear：清除所有
      //遍历方//法keys()/values()/entries()/forEach
      let map = new Map();
      console.log(map); //Map(0) {}
      let json = {
        a: 1,
        b: 2,
      };
      map.set('a', 'aaa');
      console.log(map); //Map(1) {"a" => "aaa"}
      console.log(map.size); //1
      map.set(json, 'aaa');
      map.set('aaa', json);
      console.log(map.get(json)); //aaa
      console.log(map.get('aaa')); //{a: 1, b: 2}
      map.delete('aaa');
      console.log(map.get('aaa')); //undefined
      console.log(map.has('aaa')); //false
      console.log(map); //{"a" => "aaa", {…} => "aaa"}
      map.clear();
      console.log(map); //Map(0) {}
    </script>
  </body>
</html>
